<?php
	class mxe extends connect_db{
		protected $_tenxe;
		protected $_hinhanh;
		protected $_kiemduyet;
		protected $_hang;
		protected $_loai;
		protected $_u;
		protected $_trangthai;
		protected $_gia;
		
		public function __construct(){
			$this->connect();
		}
		public function setxe($t){
			$this->_tenxe = $t;
		}
		public function getxe(){
			return $this->_tenxe;
		}
		public function sethinhanh($img){
			$this->_hinhanh = $img;
		}
		public function gethinhanh(){
			return $this->_hinhanh;
		}
		public function setkiemduyet($duyet){
			$this->_kiemduyet = $duyet;
		}
		public function getkiemduyet(){
			return $this->_kiemduyet;
		}
		public function sethang($hang){
			$this->_hang = $hang;
		}
		public function gethang(){
			return $this->_hang;
		}
		public function setloai($loai){
			$this->_loai = $loai;
		}
		public function getloai(){
			return $this->_loai;
		}
		public function setuser($us){
			$this->_u = $us;
		}
		public function getuser(){
			return $this->_u;
		}
		public function settrangthai($t){
			$this->_trangthai = $t;
		}
		public function gettrangthai(){
			return $this->_trangthai;
		}
		public function setgia($gia){
			$this->_gia = $gia;
		}
		public function getgia(){
			return $this->_gia;
		}
		
		public function listxe(){
			$sql = "select * from xe as x, hangsx as h, loaixe as l, loaitrangthai as tt, user as u where x.hang_id = h.hang_id and x.loai_id = l.loaixe_id and x.loaitt_id = tt.loaitt_id and x.user_id = u.user_id order by x.xe_id desc";
			$this->query($sql);
			if($this->num_rows() == 0){
				return false;
			}else{
				while($row = $this->fetch() ){
					$data[] = $row;
				}
				return $data;
			}
		}
		public function listxe1($id){
			$sql = "select * from xe where xe_id='$id'";
			$this->query($sql);
			return $this->fetch();
		}
		public function add(){
			$sql = "insert into xe(tenxe,hinhanh,kiemduyet,hang_id,loai_id,user_id,loaitt_id,gia)
			values('".$this->getxe()."','".$this->gethinhanh()."','".$this->getkiemduyet()."','".$this->gethang()."','".$this->getloai()."','".$this->getuser()."','".$this->gettrangthai()."','".$this->getgia()."')";
			$this->query($sql);
		}
		public function del($id){
			$sql = "delete from xe where xe_id='$id'";
			$this->query($sql);
		}
		public function edit($id){
			$sql = "update xe set
			tenxe = '".$this->getxe()."', hinhanh = '".$this->gethinhanh()."', kiemduyet = '".$this->getkiemduyet()."', hang_id = '".$this->gethang()."', loai_id = '".$this->getloai()."', loaitt_id = '".$this->gettrangthai()."', gia = '".$this->getgia()."' where xe_id = '$id' ";
			$this->query($sql);
		}
	}
?>